<template>
	<view>
		<!-- 添加赛事 发起合买 动态添加按钮-->
		<view class="game_content_box">
			<uni-swipe-action>
				<uni-swipe-action-item class="content-list" v-for="(itme,index) in cardContent" :key="index"
					:right-options='options' @click='options_Click(index)'>
					<view style="margin:15rpx 0rpx 15rpx 15rpx;">
						{{itme.leagueAbbName}} / {{itme.matchNumStr}}
					</view>
					<view class="game_title">
						<view class="title_itme">
							<text style="font-size:32rpx;">{{itme.homeTeamAbbName}}</text>
							<text v-if="itme.goal"
								:style="Number(itme.goal)>0?'color:red;':'color:green;'">{{itme.goal}}</text><br>
							<text v-if="itme.size" style="color:blue;">{{itme.size}}</text>
						</view>
						<view class="title_itme" style="flex:0.3;">VS</view>
						<view class="title_itme">{{itme.awayTeamAbbName}}</view>
					</view>
					<view class="game_content">
						<text v-for="(item2,index2) in itme.data" style="margin:20rpx;">{{item2.res}}</text>
					</view>
				</uni-swipe-action-item>
			</uni-swipe-action>
			<uni-group class="lastCard">
				<view v-if="cardContent.length!=0">您已选择{{cardContent.length}}场比赛</view>
				<!-- <view v-else>还未选择比赛</view> -->
				<view v-show="counter.BettingContent.type == '北京单场'|| counter.BettingContent.type == '胜负过关'">
					温馨提示：北单奖金计算公式=2X所有场次的开奖sp值X0.65X倍数
				</view>
			</uni-group>
		</view>


		<!-- 底部导航 -->
		<view class="footer" v-if="cardContent.length>0">
			<Goodnav :ismnshow="ismnshow" :hidetext="hidetext" :mnhideList="mnhideListdata" :hideList="hideListdata"
				:valuesdata="valuesdata" :Type="counter.BettingContent.type" @hidelick="hidelick"
				@mnhidelick="mnhidelick" @changMultiple="changMultiple" @buttonClick="buttonClick" @initData="emptyData"
				@savePlan="savePlan" :BonusOptimization='counter.gameAstrict.BonusOptimization' v-if="show_DataList">
			</Goodnav>
			<button class="sharebtn" open-type="share">分享</button>
		</view>
	</view>
</template>


<script>
	import Goodnav from "@/components/nav/yc-submit-nav.vue";
	import common from '@/common/common';
	import {
		sharesave,
		shareget
	} from '@/api/public.js'
	export default {
		components: {
			Goodnav
		},
		data() {
			return {
				isAdult:0,
				r: [],
				// 卡片内容，从jczq页面获取的，这里假设从Vuex的counter模块获取相关数据
				cardContent: [],
				// 用于渲染卡片数据的信息，隐藏列表数据
				hideListdata: [],
				mnhideListdata: [],
				// 是否显示多串过关相关
				ismnshow: false,
				// 多串过关字典
				mndata: [{
						id: 3,
						data: ['3串3', '3串4'],
						mndata: ['2串1', '2串1,3串1'],
						rcc: [1, 1],
						mnmoney: [6, 8]
					},
					{
						id: 4,
						data: ['4串4', '4串5', '4串6', '4串11'],
						mndata: ['3串1', '3串1,4串1', '2串1', '2串1,3串1,4串1'],
						rcc: [1, 1, 2, 2],
						mnmoney: [8, 10, 12, 22]
					},
					{
						id: 5,
						data: ['5串5', '5串6', '5串10', '5串16', '5串20', '5串26'],
						mndata: ['4串1', '4串1,5串1', '2串1', '3串1,4串1,5串1', '2串1,3串1', '2串1,3串1,4串1,5串1'],
						rcc: [1, 1, 3, 2, 3, 3],
						mnmoney: [10, 12, 20, 32, 40, 52]
					},
					{
						id: 6,
						data: ['6串6', '6串7', '6串15', '6串20', '6串22', '6串35', '6串42', '6串50', '6串57'],
						mndata: ['5串1', '5串1,6串1', '2串1', '3串1', '4串1,5串1,6串1', '2串1,3串1', '3串1,4串1,5串1,6串1',
							'2串1,3串1,4串1', '2串1,3串1,4串1,5串1,6串1'
						],
						rcc: [1, 1, 4, 3, 2, 4, 3, 4, 4],
						mnmoney: [12, 14, 30, 40, 44, 70, 84, 100, 114]
					},
					{
						id: 7,
						data: ['7串7', '7串8', '7串21', '7串35', '7串120'],
						mndata: ['6串1', '6串1,7串1', '5串1', '4串1', '2串1,3串1,4串1,5串1,6串1,7串1'],
						rcc: [1, 1, 2, 3, 5],
						mnmoney: [14, 16, 42, 70, 240]
					},
					{
						id: 8,
						data: ['8串8', '8串9', '8串28', '8串56', '8串70', '8串247'],
						mndata: ['7串1', '7串1,8串1', '6串1', '5串1', '4串1', '2串1,3串1,4串1,5串1,6串1,7串1,8串1'],
						rcc: [1, 1, 2, 3, 4, 5],
						mnmoney: [16, 18, 56, 112, 140, 494]
					}
				],
				// 隐藏列表相关配置
				hidelist: ['1单关1', '2串1', '3串1', '4串1', '5串1', '6串1', '7串1', '8串1', '9串1', '10串1', '11串1', '12串1', '13串1',
					'14串1', '15串1'
				],
				// 玩法字典
				game: {
					'竞彩足球': [
						['胜', '平', '负'],
						['让胜', '让平', '让负'],
						['0', '1', '2', '3', '4', '5', '6', '7+'],
						['胜-胜', '胜-平', '胜-负', '平-胜', '平-平', '平-负', '负-胜', '负-平', '负-负'],
						['1:0', '2:0', '2:1', '3:0', '3:1', '3:2', '4:0', '4:1', '4:2', '5:0', '5:1', '5:2', '胜其它',
							'0:0', '1:1', '2:2', '3:3', '平其它', '0:1', '0:2', '1:2', '0:3', '1:3', '2:3', '0:4', '1:4',
							'2:4', '0:5', '1:5', '2:5', '负其它'
						]
					],
					'竞彩篮球': [
						['胜', '负'],
						['让胜', '让负'],
						['大', '小'],
						['客胜1~5', '客胜6~10', '客胜11~15', '客胜16~20', '客胜21~25', '客胜26+', '主胜1~5', '主胜6~10', '主胜11~15',
							'主胜16~20', '主胜21~25', '主胜26+'
						]
					],
					'胜负过关': [
						['胜', '负']
					],
					'北京单场': [
						['胜', '平', '负'],
						['上单', '上双', '下单', '下双'],
						['0', '1', '2', '3', '4', '5', '6', '7+'],
						['胜-胜', '胜-平', '胜-负', '平-胜', '平-平', '平-负', '负-胜', '负-平', '负-负'],
						['1:0', '2:0', '2:1', '3:0', '3:1', '3:2', '4:0', '4:1', '4:2', '胜其它', '0:0', '1:1', '2:2',
							'3:3', '平其它', '0:1', '0:2', '1:2', '0:3', '1:3', '2:3', '0:4', '1:4', '2:4', '负其它'
						]
					]
				},
				// 头部按钮的控制信息
				headButton: [{
						id: 0,
						text: "+添加赛事",
						show: true
					},
					{
						id: 1,
						text: "发起合买",
						show: true
					},
					{
						id: 2,
						text: "发起跟单",
						show: true
					}
				],
				// 自由过关选择
				hidetext: [],
				// 多串过关选择相关的文本
				mntext: [],
				// 底部组件数据
				valuesdata: {
					Note: 0,
					Multiple: 50,
					Amount: 0,
					reachType: [],
					bonusmin: 0,
					bonusmax: 0,
					isComplex: false,
					Repeat: '0'
				},
				// 用户金额相关
				user_money: 0,
				betmoney: 0,
				orderid: 0,
				show_DataList: true,
				options: [{
					text: '删除',
					style: {
						backgroundColor: '#ff4c4c'
					}
				}]
			};
		},
		mounted() {
			// showSpell() //是否显示跟单

			// this.hidetextInit() //过关方式生成

			// console.log(this.$store.state.counter.BettingContent.Content)
			// 可以在这里放置类似原来onBeforeMount里需要执行的初始化逻辑，或者其他首次加载相关逻辑
		},
		 onLaunch: function(options) {
			},
		onShow: function(options) {
		},
		onLoad: function(options) {
		    console.log('接收到的 options:', options); // 检查参数是否正确
		    if (options.id) {
		        shareget(options.id).then(res => { // 使用 options.id 而非 options.time
				   this.$store.dispatch('updateSharedData', res.data);
				   console.log(this.$store.state.counter)
				   this.cardContent = this.$store.state.counter.BettingContent.Content;
				   this.valuesdata =  this.$store.state.counter.BettingContent.valuesdata;
		           this.hidetextInit();
		        });
		    } else {
		        this.cardContent = this.$store.state.counter.BettingContent.Content;
		        this.hidetextInit();
		    }
			this.isAdult = uni.getStorageSync("isAdult")
		},
		onShareAppMessage: async function() {
			let obj = this.$store.state.counter.BettingContent;
			obj.valuesdata=this.valuesdata
		    const res = await sharesave(obj); // 确保等待异步完成
		    let sharePath = `/pages/submit/submit_ticai?id=${encodeURIComponent(res.data)}`;
		    console.log('分享路径:', sharePath);
		    return {
		        title: "计算结果",
		        path: sharePath,
		    };
		},
		activated() {
			this.showSpell();
			if (this.$store.state.counter.BettingContent.type == '任选九' || this.$store.state.counter.BettingContent.type ==
				'胜负彩') {
				this.newNoteinit();
				var gameLength = this.$store.state.counter.BettingContent.type == '任选九' ? 9 : this.$store.state.counter
					.BettingContent.type == '胜负彩' ? 14 : 1;
				this.valuesdata.Note = common.NoteCompute(newNoteData, gameLength);
				this.valuesdata.Amount = common.ComputeAmount(this.valuesdata.Note, this.valuesdata.Multiple);
			} else {
				this.hidetextInit();
			}
		},
		
		methods: {
			isComplex() {
				var bool = false;
				for (var a = 0; a < this.$store.state.counter.BettingContent.Content.length; a++) {
					for (var c = 0; c < this.$store.state.counter.BettingContent.Content[a].data.length; c++) {
						var index = null;
						for (var s = 0; s < this.game[this.$store.state.counter.BettingContent.type].length; s++) {
							var index2 = this.game[this.$store.state.counter.BettingContent.type][s].findIndex(item =>
								item == this.$store.state.counter.BettingContent.Content[a].data[c].res);
							if (index2 != -1) {
								break;
							}
						}
						if (c == 0) {
							index = index2;
						} else {
							bool = index == index2 ? false : true;
						}
					}
				}
				return bool;
			},
			emptyData() {
				uni.showLoading({
					title: '删除中',
					mask: true
				});
				var timeovr = 200;
				var newTime = 200 * this.$store.state.counter.BettingContent.Content.length;
				for (var i = 0; i < this.$store.state.counter.BettingContent.Content.length; i++) {
					timeovr = timeovr + 100;
					setTimeout(() => {
						this.$store.state.counter.styleData.data = [];
						this.$store.state.counter.styleData.data.push(this.$store.state.counter.BettingContent
							.Content[0].matchId);
						this.$store.state.counter.BettingContent.Content.splice(0, 1);
					}, timeovr);
				}
				this.hideListdata.splice(0, this.hideListdata.length);
				this.hidetext.splice(0, this.hidetext.length);
				this.mnhideListdata.splice(0, this.mnhideListdata.length);
				this.valuesdata.Amount = 0;
				this.valuesdata.bonusmax = 0;
				this.valuesdata.bonusmin = 0;
				this.valuesdata.Note = 0;
				setTimeout(() => {
					uni.hideLoading();
				}, newTime);
			},
			showSpell() {
				if (this.$store.state.counter.gameAstrict.Issuing_switch == 1) {
					if (this.$store.state.counter.BettingContent.type == '任选九' || this.$store.state.counter.BettingContent
						.type == '胜负彩') {
						this.headButton.splice(this.headButton.length - 1, 1);
					}
				} else {
					this.headButton.splice(this.headButton.length - 1, 1);
				}
			},
			action(id) {
				this.valuesdata.reachType = this.hidetext;
				this.$store.state.counter.BettingContent.remarks = this.valuesdata;
				delete this.$store.state.counter.BettingContent.bonusOptimize;
				if (id == 0) {
					this.back();
				} else if (id == 1) {
					if (this.hidetext.length === 0 && this.$store.state.counter.BettingContent.type != '任选九' && this.$store
						.state.counter.BettingContent.type != '胜负彩') {
						uni.showToast({
							icon: "error",
							title: '请选择过关方式',
							duration: 2000
						});
					} else if (this.valuesdata.Amount < 10) {
						uni.showToast({
							icon: "none",
							title: '订单金额不能小于10元',
							duration: 2000
						});
					} else {
						uni.navigateTo({
							url: '../submit/buyTogether?Amount=' + this.valuesdata.Amount + '&Note=' + this
								.valuesdata.Note + '&bonusmin=' + this.valuesdata.bonusmin * this.valuesdata
								.Multiple + '&bonusmax=' + this.valuesdata.bonusmax * this.valuesdata.Multiple +
								'&lssue=' + this.$store.state.counter.BettingContent.lssue
						});
						this.$store.state.counter.BettingContent.remarks = this.valuesdata;
					}
				} else if (id == 2) {
					if (this.hidetext.length == 0) {
						uni.showToast({
							icon: "error",
							title: '请选择过关方式',
							duration: 2000
						});
					} else if (this.valuesdata.Amount < 100) {
						uni.showToast({
							icon: "none",
							title: '发单投注金额最小100元！',
							duration: 2000
						});
					} else {
						uni.navigateTo({
							url: '../submit/spell?Amount=' + this.valuesdata.Amount + '&Note=' + this.valuesdata
								.Note + '&bonusmin=' + this.valuesdata.bonusmin * this.valuesdata.Multiple +
								'&bonusmax=' + this.valuesdata.bonusmax * this.valuesdata.Multiple + '&lssue=' +
								this.$store.state.counter.BettingContent.lssue
						});
					}
				}
			},
			back() {
				uni.navigateBack();
			},
			hidetextInit() {
				this.hidetext.length = 0;
				this.hideListdata.length = 0;
				var newIsDan = !this.isDan();
				var game_length_number = this.$store.state.counter.BettingContent.Content.length;
				console.log(this.$store.state.counter.BettingContent)
				console.log("@1>>>>>>",this.$store.state.counter.BettingContent.type == '竞彩足球' && this.isAstrict_football())
				if (this.$store.state.counter.BettingContent.type == '竞彩足球' && this.isAstrict_football()) {
					if (game_length_number > 4) {
						for (var i = 0; i < 4; i++) {
							this.hideListdata.push({
								id: newIsDan ? i - 1 : i,
								text: this.hidelist[i],
								isActive: false
							});
						}
						uni.showToast({
							title: '四场以上比分、半全场不允许4串以上的玩法喔~',
							icon: 'none',
							position: 'center'
						});
					} 
					else {
						for (var i = 0; i < game_length_number; i++) {
							this.hideListdata.push({
								id: newIsDan ? i - 1 : i,
								text: this.hidelist[i],
								isActive: false
							});
						}
						console.log(this.hideListdata)
						this.mnhideListdataInit();
					}
					if (!newIsDan) {
						this.hideListdata.splice(0, 1);
					}
					this.hidelick(this.hideListdata[this.hideListdata.length - 1]);
					return;
				}
					console.log("@2>>>>>>",this.$store.state.counter.BettingContent.type == '竞彩足球' && this.iszjq())
				if (this.$store.state.counter.BettingContent.type == '竞彩足球' && this.iszjq()) {
					if (game_length_number > 6) {
						for (var i = 0; i < 6; i++) {
							this.hideListdata.push({
								id: newIsDan ? i - 1 : i,
								text: this.hidelist[i],
								isActive: false
							});
						}
						uni.showToast({
							title: '总进球不允许6串以上的玩法喔~',
							icon: 'none',
							position: 'center'
						});
					}
					 else {
						for (var i = 0; i < game_length_number; i++) {
							this.hideListdata.push({
								id: newIsDan ? i - 1 : i,
								text: this.hidelist[i],
								isActive: false
							});
						}
						console.log(this.hideListdata)
						this.mnhideListdataInit();
					}
					if (!newIsDan) {
						this.hideListdata.splice(0, 1);
					}
					this.hidelick(this.hideListdata[this.hideListdata.length - 1]);
					return;
				}
			
				for (var i = 0; i < game_length_number; i++) {
					this.hideListdata.push({
						id: newIsDan ? i - 1 : i,
						text: this.hidelist[i],
						isActive: false
					});
				}
				this.mnhideListdataInit();
				
				if (newIsDan) {
					this.hideListdata.splice(0, 1);
				}
				// console.log(this.hideListdata)
				this.hidelick(this.hideListdata[this.hideListdata.length - 1]);
			},
			mnhideListdataInit() {
				for (var i = 0; i < this.mndata.length; i++) {
					if (this.mndata[i].id == this.hideListdata.length) {
						for (var j = 0; j < this.mndata[i].data.length; j++) {
							this.mnhideListdata.push({
								id: j,
								text: this.mndata[i].data[j],
								isActive: false
							});
						}
						this.ismnshow = true;
						break;
					}
				}
			},
			iszjq() {
				var arr = ['jq'];
				var isAstr = false;
				for (var i = 0; i < this.$store.state.counter.BettingContent.Content.length; i++) {
					for (var j = 0; j < this.$store.state.counter.BettingContent.Content[i].data.length; j++) {
						if (arr.indexOf(this.$store.state.counter.BettingContent.Content[i].data[j].gameState) != -1) {
							isAstr = true;
							break;
						}
					}
					if (isAstr) {
						break;
					}
				}
				return isAstr;
			},
			isAstrict_football() {
				var arr = ['bf', 'bqc'];
				var isAstr = false;
				for (var i = 0; i < this.$store.state.counter.BettingContent.Content.length; i++) {
					for (var j = 0; j < this.$store.state.counter.BettingContent.Content[i].data.length; j++) {
						if (arr.indexOf(this.$store.state.counter.BettingContent.Content[i].data[j].gameState) != -1) {
							isAstr = true;
							break;
						}
					}
					if (isAstr) {
						break;
					}
				}
				return isAstr;
			},
			isAstrict_basketball() {
				var isAstr = false;
				for (var i = 0; i < this.$store.state.counter.BettingContent.Content.length; i++) {
					for (var j = 0; j < this.$store.state.counter.BettingContent.Content[i].data.length; j++) {
						if (this.$store.state.counter.BettingContent.Content[i].data[j].gameState == 'sfc') {
							isAstr = true;
							break;
						}
					}
					if (isAstr) {
						break;
					}
				}
				return isAstr;
			},
			isDan() {
				var newIsDan = true;
				for (var i = 0; i < this.$store.state.counter.BettingContent.Content.length; i++) {
					for (var j = 0; j < this.$store.state.counter.BettingContent.Content[i].data.length; j++) {
						if (this.$store.state.counter.BettingContent.Content[i].data[j].poolEs != 1) {
							newIsDan = false;
							break;
						}
						if (!newIsDan) {
							break;
						}
					}
				}
				return newIsDan;
			},
			hidelick(e) {
				if (e.isActive == false) {
					if (this.mntext != '') {
						for (var i = 0; i <= this.mnhideListdata.length - 1; i++) {
							this.mnhideListdata[i].isActive = false;
						}
						this.hidetext.splice(this.hidetext.indexOf(this.mntext), 1);
						this.mntext = '';
						this.valuesdata.Note = 0;
					}
					this.hidetext.push(e.text);
					var data = this.mnhidelickNote(this.$store.state.counter.BettingContent.Content, this.hidetext, this
						.valuesdata.Multiple, "0");
					this.valuesdata.Note = data.note;
					this.valuesdata.Amount = data.betMoney;
					this.valuesdata.bonusmax = data.maxMoney;
					this.valuesdata.bonusmin = data.minMoney;
				} else {
					this.hidetext.splice(this.hidetext.indexOf(e.text), 1);
					var data = this.mnhidelickNote(this.$store.state.counter.BettingContent.Content, this.hidetext, this
						.valuesdata.Multiple, "0");
					this.valuesdata.Note = data.note;
					this.valuesdata.Amount = data.betMoney;
					this.valuesdata.bonusmax = data.maxMoney;
					this.valuesdata.bonusmin = data.minMoney;
				}
				this.hideListdata[e.id].isActive = !this.hideListdata[e.id].isActive;
			},
			mnhidelick(e) {
				this.hidetext.splice(0, this.hidetext.length);
				if (e.isActive == false) {
					for (var i = 0; i <= this.hideListdata.length - 1; i++) {
						this.hideListdata[i].isActive = false;
					}
					for (var i = 0; i <= this.mnhideListdata.length - 1; i++) {
						this.mnhideListdata[i].isActive = false;
					}
					this.hidetext.push(e.text);
					this.mnhideListdata[e.id].isActive = true;
					var data = this.mnhidelickNote(this.$store.state.counter.BettingContent.Content, this.hidetext, this
						.valuesdata.Multiple, "0");
					this.valuesdata.Note = data.note;
					this.valuesdata.Amount = data.betMoney;
					this.valuesdata.bonusmax = data.maxMoney;
					this.valuesdata.bonusmin = data.minMoney;
				} else {
					this.hidetext.splice(this.hidetext.indexOf(e.text), 1);
					this.mnhideListdata[e.id].isActive = false;
					var data = this.mnhidelickNote(this.$store.state.counter.BettingContent.Content, this.hidetext, this
						.valuesdata.Multiple, "0");
					this.valuesdata.Note = data.note;
					this.valuesdata.Amount = data.betMoney;
					this.valuesdata.bonusmax = data.maxMoney;
					this.valuesdata.bonusmin = data.minMoney;
				}
				this.mntext = e.text;
			},
			mnhidelickNote(orderData, hidetextArr, beilv, repeat) {
				console.log("orderData",orderData)
				console.log("hidetextArr",hidetextArr)
				console.log("beilv",beilv)
				console.log("repeat",repeat)
				var betInfo = {
					'note': 0,
					'maxMoney': 0,
					'minMoney': 0,
					'betMoney': 0
				};
				if (orderData.length == 1 && hidetextArr[0] == '单关') {
					betInfo.note = 0;
					var moneyArr = [];
					orderData[0].data.forEach((itme, index) => {
						betInfo.note++;
						moneyArr.push(itme.rate * 2);
					});
					betInfo.betMoney = (betInfo.note * 2) * beilv;
					betInfo.maxMoney = Math.max(...moneyArr);
					betInfo.minMoney = Math.min(...moneyArr);
					return betInfo;
				}
				if (hidetextArr.length == 0) {
					return betInfo;
				}
				var hidetextBoole = false;
				for (var ii = 0; ii <= hidetextArr.length - 1; ii++) {
					if (hidetextArr[ii].split('串')[1] != 1) {
						hidetextBoole = true;
					}
				}
				var formattedOrderData = this.initDispose(orderData);
				var formattedHidetextArr = this.initHidetext(hidetextArr);
				var oneCombinationData = [];
				if (repeat == 0 && !hidetextBoole) {
					oneCombinationData = this.nonredundantData(formattedOrderData, formattedHidetextArr);
					
				} else {
					oneCombinationData = this.repetitive(formattedOrderData, formattedHidetextArr);
				}
				return this.noteMoney(oneCombinationData, beilv, repeat, hidetextBoole);
			},
			noteMoney(data, beilv, repeat, hidetextBoole) {
				var initArr = {
					'note': 0,
					'maxMoney': 0,
					'minMoney': 0,
					'betMoney': 0
				};
				var iData = JSON.parse(JSON.stringify(data));
				var initData = this.CombinationFormatted(iData);
				var newCombinationData = [];
				initData.forEach(function(itme, index) {
					var combinationData = [];
					itme.Hidetext.forEach(function(Xitme, Xindex) {
						var number = Xitme.split('串')[0];
						combinationData.push(this.combinationFunction(itme.data, number));
					}, this);
					var arr2 = combinationData.reduce(function(a, b) {
						return a.concat(b);
					});
					newCombinationData.push(arr2);
				}, this);
				newCombinationData.forEach(function(itme, index) {
					initArr.note += itme.length;
				});
				var money = this.noteFuncion(data, beilv, repeat);
				if (this.$store.state.counter.BettingContent.type == '北京单场' || this.$store.state.counter.BettingContent
					.type == '胜负过关') {
					initArr.maxMoney = money.max * 0.65;
					initArr.minMoney = money.min * 0.65;
				} else {
					initArr.maxMoney = money.max;
					initArr.minMoney = money.min;
				}
				initArr.betMoney = (initArr.note * 2) * beilv;
				return initArr;
			},
			CombinationFormatted(arr) {
				var allData = [];
				arr.forEach(function(itme, index) {
					var newArr = {
						data: [],
						Hidetext: itme.Hidetext
					};
					itme.data.forEach(function(Xitme, Xindex) {
						Xitme.split(',')[1].split('|').forEach(function(Ditme, Dindex) {
							if (Ditme != '') {
								newArr.data.push(Xitme.split(',')[0] + ',' + Ditme);
							}
						});
					});
					allData.push(newArr);
				});
				return allData;
			},
			nonredundantData(data, reachTypeArr) {
				var typeArr = [];
				reachTypeArr.hidetext.forEach(function(itme, index) {
					typeArr.push(itme.split('串')[0]);
				});
				var maxType = Math.max(...typeArr);
				var oneOrder = [];
				var oneControlGroup = [];
				for (var i = oneOrder.length; i < maxType; i++) {
					var bool = false;
					for (var f = 0; f < oneOrder.length; f++) {
						if (oneOrder[f].substring(0, 5) == data[i].substring(0, 5)) {
							bool = true;
							maxType++;
							break;
						}
					}
					if (!bool) {
						oneOrder.push(data[i]);
					}
				}
				typeArr.forEach(function(itme, index) {
					oneControlGroup.push(this.combinationFunction(oneOrder, itme));
				}, this);
				var newOneControlGroup = oneControlGroup.flat();
				var newTwoOrder = [];
				typeArr.forEach(function(Citme, Cindex) {
					var twoOrder = this.combinationFunction(data, Citme);
					twoOrder.forEach(function(itme, index) {
						var bool = false;
						for (var t = 0; t < newOneControlGroup.length; t++) {
							if (newOneControlGroup[t].toString() == itme.toString()) {
								bool = true;
								break;
							}
						}
						if (!bool) {
							var init = {
								data: itme,
								Hidetext: Array(Citme + '串1')
							};
							newTwoOrder.push(init);
						}
					});
				}, this);
				var allData = newTwoOrder;
				allData.unshift({
					data: oneOrder,
					Hidetext: reachTypeArr.hidetext
				});
				return allData;
			},
			repetitive(data, HidetextArr) {
				var minLength = [];
				var minData = [];
				for (var i = 1; i <= 10; i++) {
					if (this.combinationFunction(data, i).length == 0) {
						break;
					} else {
						minLength.push(this.combinationFunction(data, i).length);
						minData.push(i);
					}
				}
				var minIndex = minLength.indexOf(Math.min(...minLength));
				var minData = this.combinationFunction(data, minData[minIndex]);
				var maxHideText = Math.max(...HidetextArr.number);
				if (minData[0].length < maxHideText) {
					var minData = this.combinationFunction(data, maxHideText);
				}
				var allData = [];
				minData.forEach(function(itme, index) {
					var dataOjd = {
						data: itme,
						Hidetext: HidetextArr.hidetext
					};
					allData.push(dataOjd);
				});
				return allData;
			},
			initHidetext(arr) {
				var newArr = {
					hidetext: [],
					number: []
				};
				arr.forEach(function(itme, index) {
					if (itme == '1单关1') {
						newArr.hidetext.push('1串1');
					} else if (itme.split('串')[1] != 1) {
						for (var i = 0; i < this.mndata.length; i++) {
							var hidetextIndex = this.mndata[i].data.indexOf(itme, 0);
							if (hidetextIndex != -1) {
								newArr.hidetext = this.mndata[i].mndata[hidetextIndex].split(',');
								break;
							}
						}
					} else {
						newArr.hidetext.push(itme);
					}
				}, this);
				newArr.hidetext.forEach(function(itme, index) {
					newArr.number.push(Number(itme.split('串')[0]));
				});
				return newArr;
			},
			initDispose(data) {
				var initData = data;
				var oneData = [];
				initData.forEach(function(itme, index) {
					itme.data.forEach(function(Xitme, Xindex) {
						if (this.$store.state.counter.BettingContent.type == '胜负过关' || this.$store.state
							.counter.BettingContent.type == '北京单场') {
							oneData.push(
								'00' + itme.matchId + '&' + this.gameTypeIndex(Xitme.res) + ',' + Xitme
								.res + '/' + Xitme.rate + '|'
							);
						} else {
							oneData.push(
								itme.matchNumStr + '&' + this.gameTypeIndex(Xitme.res) + ',' + Xitme
								.res + '/' + Xitme.rate + '|'
							);
						}
					}, this);
				}, this);
				var list = [];
				oneData.forEach(function(itme, index) {
					list.push(itme.split(','));
				});
				var newList = this.sortClass(list, 0);
				var newOneData = [];
				newList.forEach(function(itme, index) {
					var newnew = itme[0][0];
					var text = '';
					itme.forEach(function(Xitme, Xindex) {
						text += Xitme[1];
					});
					newOneData.push(newnew + ',' + text);
				});
				return newOneData;
			},
			noteFuncion(data, beilv, repeat) {
				var newData = {
					max: 0,
					min: 0
				};
				console.log("noteFuncion",data)
				console.log("noteFuncion",beilv)
				console.log("noteFuncion",repeat)
				var initArr = data;
				var combinationArr = [];
				initArr.forEach(function(itme, index) {
					var arr = [];
					itme.Hidetext.forEach(function(Xitme, Xindex) {
						arr.push(this.combinationFunction(itme.data, Xitme.split('串')[0]));
					}, this);
					var arr2 = arr.reduce(function(a, b) {
						return a.concat(b);
					});
					combinationArr.push(arr2);
				}, this);
				var max_duizhao = {};
				var min_arr = [];
				combinationArr.forEach(function(itme, index) {
					var minRepeat = [];
					itme.forEach(function(p_itme, p_index) {
						var all_max = 1;
						var all_min = 1;
						var objKey = '';
						p_itme.forEach(function(i_itme, i_index) {
							var itemBlv = i_itme.split(',')[1].split('|');
							if (i_index == 0) {
								objKey = i_itme.split('&')[0];
							} else {
								objKey += '|' + i_itme.split('&')[0];
							}
							var max_number = 0;
							var min_number = 0;
							itemBlv.forEach(function(x_itme, x_index) {
								if (x_itme != '') {
									var newNumber = Number(x_itme.split('/')[1]);
									max_number = newNumber > max_number ? newNumber :
										max_number;
									if (x_index == 0) {
										min_number = newNumber;
									} else {
										min_number = newNumber < min_number ? newNumber :
											min_number;
									}
								}
							});
							all_max *= max_number;
							all_min *= min_number;
						});
						if (!max_duizhao[objKey]) {
							max_duizhao[objKey] = [];
						}
						var xianzhi_max = all_max * 2;
						if (p_itme.length == 1 && xianzhi_max > 100000) {
							xianzhi_max = 100000;
						} else if (p_itme.length >= 2 && p_itme.length <= 3 && xianzhi_max > 200000) {
							xianzhi_max = 200000;
						} else if (p_itme.length >= 4 && p_itme.length <= 5 && xianzhi_max > 500000) {
							xianzhi_max = 500000;
						} else if (p_itme.length >= 6 && xianzhi_max > 1000000) {
							xianzhi_max = 1000000;
						}
						max_duizhao[objKey].push(xianzhi_max);
						newData.max += xianzhi_max;
						var xianzhi_min = all_min * 2;
						if (p_itme.length == 1 && xianzhi_min > 100000) {
							xianzhi_min = 100000;
						} else if (p_itme.length >= 2 && p_itme.length <= 3 && xianzhi_min > 200000) {
							xianzhi_min = 200000;
						} else if (p_itme.length >= 4 && p_itme.length <= 5 && xianzhi_min > 500000) {
							xianzhi_min = 500000;
						} else if (p_itme.length >= 6 && xianzhi_min > 1000000) {
							xianzhi_min = 1000000;
						}
						min_arr.push(xianzhi_min);
						minRepeat.push(xianzhi_min);
					});
					newData.min += Math.min(...minRepeat);
				});
				// if (repeat == '0') {
					newData.max = 0;
					for (var key in max_duizhao) {
						newData.max += Math.max(...max_duizhao[key]);
					}
					newData.min = Math.min(...min_arr);
				// }
				return newData;
			},
			gameTypeIndex(title) {
				for (var d = 0; d < this.game[this.$store.state.counter.BettingContent.type].length; d++) {
					for (var e = 0; e < this.game[this.$store.state.counter.BettingContent.type][d].length; e++) {
						var index = this.game[this.$store.state.counter.BettingContent.type][d].findIndex(item => item ==
							title);
						if (index != -1) {
							return d;
							break;
						}
					}
				}
			},
			sortClass(sortData, number) {
				let groups = {};
				sortData.forEach((o) => {
					let group = JSON.stringify(o[number]);
					groups[group] = groups[group] || [];
					groups[group].push(o);
				});
				return Object.keys(groups).map((group) => {
					return groups[group];
				});
			},
			combinationFunction(arr, m) {
				this.r = [];
				this.temporary([], arr, m);
				var repetition = [];
				for (var o = 0; o < this.r.length; o++) {
					var arr = [];
					for (var p = 0; p < this.r[o].length; p++) {
						arr.push(this.r[o][p].substring(0, 5));
					}
					if (!this.isRepeat(arr)) {
						repetition.push(this.r[o]);
					}
				}
				return repetition;
			},
			isRepeat(ary) {
				var a = false;
				for (var i = 0; i < ary.length; i++) {
					if (ary.indexOf(ary[i]) != i) {
						a = true;
					}
				}
				return a;
			},
			temporary(t, a, m) {
				if (m === 0) {
					this.r[this.r.length] = t;
					return;
				}
				for (let i = 0; i <= a.length - m; i++) {
					let b = t.slice();
					b.push(a[i]);
					this.temporary(b, a.slice(i + 1), m - 1);
				}
			},
			buttonClick() {
				if (this.$store.state.counter.BettingContent.type == '任选九' && this.$store.state.counter.BettingContent
					.Content.length == 9) {
					this.betmoney = this.valuesdata.Amount;
					this.user_money = this.$store.state.counter.user_money;
					this.$refs.popup.open("bottom");
				} else if (this.$store.state.counter.BettingContent.type == '胜负彩' && this.$store.state.counter
					.BettingContent.Content.length == 14) {
					this.betmoney = this.valuesdata.Amount;
					this.user_money = this.$store.state.counter.user_money;
					this.$refs.popup.open("bottom");
				} else {
					if (this.$store.state.counter.BettingContent.type == '任选九' || this.$store.state.counter.BettingContent
						.type == '胜负彩') {
						uni.showToast({
							title: '未选够比赛场次',
							icon: 'error'
						});
					} else {
						if (this.hidetext.length > 0) {
							this.betmoney = this.valuesdata.Amount;
							this.user_money = this.$store.state.counter.user_money;
							this.$refs.popup.open("bottom");
						} else {
							uni.showToast({
								title: '请选择过关方式',
								icon: 'error',
								position: 'center'
							});
						}
					}
				}
			},
			changMultiple(e) {
				this.valuesdata.Multiple = e;
				this.valuesdata.Amount = common.ComputeAmount(this.valuesdata.Note, this.valuesdata.Multiple);
				 this.$store.dispatch('updatevaluesdata', this.valuesdata);
			},
			getNewMoney() {

			},
			ConfirmPayment() {

			},
			closeOrder() {
				this.$refs.infopopup.close();
				setTimeout(() => {
					uni.navigateBack({
						delta: 1,
						success: (res) => {
							setTimeout(() => {
								this.$store.state.counter.BettingContent = [];
							}, 60);
						}
					});
				}, 300);
			},
			newNoteinit() {
				this.newNoteData.splice(0, this.newNoteData.length);
				var number = this.$store.state.counter.BettingContent.Content.length;
				for (var i = 0; i <= number - 1; i++) {
					var count = this.$store.state.counter.BettingContent.Content[i].data.length;
					this.newNoteData.push(count);
				}
			},
			options_Click(e) {
				this.$store.state.counter.styleData.data.push(this.$store.state.counter.BettingContent.Content[e].matchId);
				this.$store.state.counter.BettingContent.Content.splice(e, 1);
				this.hideListdata.splice(0, thishideListdata.length);
				this.hidetext.splice(0, this.hidetext.length);
				this.mnhideListdata.splice(0, this.mnhideListdata.length);
				if (this.$store.state.counter.BettingContent.type == '竞彩足球' || this.$store.state.counter.BettingContent
					.type == '竞彩篮球') {
					if (this.$store.state.counter.BettingContent.Content.length < 2 && !this.isDan()) {
						this.back();
						uni.showToast({
							title: '请再选择一场比赛',
							icon: "none",
							position: 'center'
						});
					} else if (this.$store.state.counter.BettingContent.Content.length == 0) {
						this.back();
					} else {
						this.hidetextInit();
					}
					return;
				}
				if (this.$store.state.counter.BettingContent.type == '任选九' || this.$store.state.counter.BettingContent
					.type == '胜负彩') {
					this.newNoteinit();
				} else {
					this.hidetextInit();
				}
				this.show_DataList = false;
				this.$nextTick(() => {
					this.show_DataList = true;
				});
			},
			savePlan() {

			}
		}
	};
</script>

<style lang="less">
	.navBar {
		width: 100%;
		height: 80rpx;
		display: flex;
		background-color: #f04b49;
		line-height: 80rpx;
		box-shadow: 0px 5rpx 15rpx 5rpx rgba(226, 226, 226, 0.4);
		justify-content: space-between;
		padding-top: var(--status-bar-height);
		z-index: 2;
		position: -webkit-sticky;
		position: sticky;
		top: 0rpx;

		.navBar_left {
			display: flex;
			align-items: center;
			width: 120rpx;
			margin-left: 20rpx;
		}

		.navBar_right {
			width: 120rpx;
			margin-right: 20rpx;
		}
	}


	.footer {
		position: fixed;
		bottom: 0;
		left: 0;
		width: 100%;
	}

	.head {
		display: flex;
		margin: 20rpx 0;
		flex-direction: row;
		justify-content: space-around;
	}

	.head .button {
		text-align: center;
		line-height: 70rpx;
		font-size: 34rpx;
		margin: 0 10rpx;
		height: 70rpx;
		width: 80%;
		border-radius: 15rpx;
		background-color: #fff;
		box-shadow: 0px 5rpx 15rpx 5rpx rgba(226, 226, 226, 0.4);
	}

	.game_content_box {
		padding-bottom: 220rpx;
	}

	.game_content {
		width: 685rpx;
		background-color: #f5f5f5;
		margin: 15rpx auto;
		border-radius: 10rpx;
		display: flex;
		justify-content: center;
		align-items: center;
		flex-wrap: wrap;
		color: #f04b49;
		text-align: center;
	}

	.lastCard {
		text-align: center;
		color: #666;
		padding-bottom: 10rpx;
		border-bottom: 3rpx dashed #777;
		background-color: white;
		border-radius: 15rpx 15rpx 0 0;
		box-shadow: 0px 5rpx 15rpx 5rpx rgba(226, 226, 226, 0.4);
	}

	.game_title {
		display: flex;

		.title_itme {
			flex: 1;
			text-align: center;
			margin: 0rpx 15rpx;
			font-size: 32rpx;
			font-weight: bold;
			color: #313131;

			text {
				font-size: 32rpx;
				font-weight: bold;
				color: #313131;
			}
		}
	}

	.content-list {
		width: 730rpx;
		border-radius: 15rpx;
		background-color: #ffffff;
		box-shadow: 0px 5rpx 15rpx 5rpx rgba(226, 226, 226, 0.4);
		margin: 20rpx auto;
	}

	body {
		background-color: #fbfbfb;
	}

	.sharebtn {
		position: absolute;
		bottom: 136px;
		right: 15px;
		background-color: #4fce4a;
		border-radius: 30px;
		padding: 10px;
		width: 80px;
		display: flex;
		justify-content: center;
	}
</style>